package com.njue.mis.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;


public class MainFrame extends JFrame
{
	public static String power;
	public static String username;
	
	private JDesktopPane desktopPane;
	private static MainFrame mainFrame;
	/**
	 * ��������
	 */
	private MainFrame()
	{
		super("管理系统");

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds(screenSize.width/6,screenSize.height/6, screenSize.width*2/3,
				screenSize.height*2/3);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		desktopPane=new JDesktopPane();
		
		desktopPane.setOpaque(true);

		this.setContentPane(desktopPane);
		this.setJMenuBar(createMenuBar());
		
		//Set up the backgound image
		desktopPane.setBackground(new Color(200,218,235));
		// 设置桌面窗格使用的“拖动样式”
		desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
                //JDesktopPane.OUTLINE_DRAG_MODE 指示桌面窗格是否只应该出现正在被拖动项的轮廓。
	}
	
	public static MainFrame getMainFrame()
	{
		if(mainFrame==null)
		{
			mainFrame=new MainFrame();
		}
		return mainFrame;
	}

		/**
	 * 创建主窗体的菜单栏
	 *
	 * @return JMenuBar
	 */
	protected JMenuBar createMenuBar()
	{
		JMenuBar menuBar = new JMenuBar();

		// Set up the info menu.
		JMenu menu = new JMenu("基础信息管理");
		menuBar.add(menu);
		JMenuItem menuItem = new JMenuItem("客户信息管理");
		menuItem.addActionListener(MainAction.clickCustomerInfoManager());
		menu.add(menuItem);
		menuItem = new JMenuItem("商品信息管理");
		menuItem.addActionListener(MainAction.clickGoodsInfoManager());
		menu.add(menuItem);
		menuItem = new JMenuItem("供应商信息管理");
		menuItem.addActionListener(MainAction.clickProviderInfoManager());
		menu.add(menuItem);

	
		return menuBar;
	}
}
